import { http } from 'utils'

export function getCountry() {
  return http
    .get('tool@getCountry')
    .then(res => res)
}

// 获取验证码
export function getVercode({ areaCode, mobile }) {
  return http
    .get('user/regCode', { areaCode, mobile })
    .then(res => res)
}

// 检验验证码
export function checkVercode({ areaCode, mobile, verificationCode }) {
  return http
    .get('user/checkRegCode', { areaCode, mobile, verificationCode })
    .then(res => res)
}

// 手机号码注册
export function registerPhone({ areaCode, mobile, mPassword, verificationCode }) {
  return http
    .post('user/regPhone', { areaCode, mobile, mPassword, verificationCode })
    .then(res => res)
}

// 邮箱注册
export function registerEmail({ email, mPassword }) {
  return http
    .post('user/regEmail', { email, mPassword })
    .then(res => res)
}

// 手机登陆
export function loginPhone({ areaCode, mobile, mPassword }) {
  return http
    .post('user/loginPhone', { areaCode, mobile, mPassword })
    .then(res => res)
}

// 邮箱登陆
export function loginEmail({ email, mPassword }) {
  return http
    .post('user/loginEmail', { email, mPassword })
    .then(res => res)
}

// 检查邮箱是否注册
export function checkEmail({ email }) {
  return http
    .get('user/checkRegEmail', { email })
    .then(res => res)
}

// 第三方联登
export function thridLogin({ openId, accessToken, type }) {
  return http
    .post('thirduser/login', { openId, accessToken, type })
    .then(res => res)
}

// 第三方账号绑定
export function thridBind({ openId, accessToken, phone, countryCode, mPassword, type }) {
  return http
    .post('thirduser/bingThirdUser', { openId, accessToken, phone, countryCode, mPassword, type })
    .then(res => res)
}
